# -*- coding: utf-8 -*-
from datetime import datetime, date
from pydantic import BaseModel, Field


class YgBase(BaseModel):
    create_by: str | None = Field(None, noneable=True)
    update_by: str | None = Field(None, noneable=True)
    del_flag: bool | None = Field(None, noneable=True)
    update_time: datetime | None = Field(datetime.now(), title="update_time", example="1990-01-01", noneable=True)
    create_time: datetime | None = Field(None, title="create_time", example="1990-01-01", noneable=True)

    class Config:
        from_attributes = True
        orm_mode = True
        json_encoders = {
            datetime: lambda v: v.strftime("%Y-%m-%d %H:%M:%S")
        }

